package com.example.concurrent.AtomicLong;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Created by SOAL on 2017/2/11 0011.
 */
public class AtomicLongDemo {

    public static void main(String[] args) {
        AtomicLong atomicLong = new AtomicLong(123);

        long theValue = atomicLong.get();

        atomicLong.set(234);

        long expectedValue = 123;
        long newValue      = 234;
        atomicLong.compareAndSet(expectedValue, newValue);


//        addAndGet()
//        getAndAdd()
//        getAndIncrement()
//        incrementAndGet()

        System.out.println(atomicLong.getAndAdd(10));
        System.out.println(atomicLong.addAndGet(10));

//        decrementAndGet()
//        getAndDecrement()

    }
}
